import 'package:shared_preferences/shared_preferences.dart';

class PreferencesManager {
  SharedPreferences _preferences;

  static final PreferencesManager _instance = PreferencesManager._internal();

  PreferencesManager._internal();

  factory PreferencesManager.getInstance() => _instance;

  Future<void> init() async =>
      _preferences = await SharedPreferences.getInstance();

  void putString(String key, String value) => _preferences.setString(key, value);

  String getString(String key) =>_preferences.getString(key) ?? "";

  void putBool(String key, bool value) => _preferences.setBool(key, value);

  bool getBool(String key) => _preferences.getBool(key) ?? false;

  void putInt(String key, int value) => _preferences.setInt(key, value);

  int getInt(String key) => _preferences.getInt(key) ?? -1;
}
